﻿using Beaker.Reflection;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Beaker.Common.Specs.Reflection
{
	[TestClass]
	public sealed class TypeInfoExtensionsSpecs
	{
		[TestMethod]
		public void GetUnderlyingTypeShouldReturnTheTypeTheArrayIsBasedOn()
		{
			typeof(sbyte[]).GetUnderlyingType()
				.Should().Be(typeof(sbyte));
		}

		[TestMethod]
		public void GetUnderlyingTypeShouldReturnTheTypeTheEnumIsBasedOn()
		{
			typeof(FiFaFoFum).GetUnderlyingType()
				.Should().Be(typeof(sbyte));
		}

		[TestMethod]
		public void GetUnderlyingTypeShouldReturnTheTypeTheMaybeWraps()
		{
			typeof(Maybe<sbyte>).GetUnderlyingType()
				.Should().Be(typeof(sbyte));
		}

		[TestMethod]
		public void GetUnderlyingTypeShouldReturnTheTypeTheNullableWraps()
		{
			typeof(sbyte?).GetUnderlyingType()
				.Should().Be(typeof(sbyte));
		}

		public enum FiFaFoFum
			: sbyte
		{
			Unknown = -1,
			None = 0,
			Known = 1
		}
	}
}
